package com.cmwa.scbp.base.mvc.entity;

import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.cmwa.scbp.sys.userInfo.entity.UserInfoVo;
import com.cmwa.scbp.utils.DateUtils;
import com.cmwa.scbp.utils.cached.EmployeeCached;

public class Employee {

	/**
	 * 员工ID
	 */
	private String ID;

	/**
	 * 员工登陆名
	 */
	private String loginName;
	private String login;
	/** 用户类型 IN OUT 内外部用户 */
	private String empType;
	private String orgName;
	private String empStat;

	/** 所属公司 */
	private String company;

	/** 所属公司名称 */
	private String companyName;

	/**
	 * 真实姓名
	 */
	private String name;

	/**
	 * 顶级部门ID
	 */
	private String topOrganid;

	/**
	 * 是否中后台角色
	 */
	private String isMiddleBack;
	
	private String dueDate;  // 到期日

	public String getID() {
		return ID;
	}

	public void setID(String iD) {
		ID = iD;
	}

	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTopOrganid() {
		return topOrganid;
	}

	public void setTopOrganid(String topOrganid) {
		this.topOrganid = topOrganid;
	}

	public String getIsMiddleBack() {
		return isMiddleBack;
	}

	public void setIsMiddleBack(String isMiddleBack) {
		this.isMiddleBack = isMiddleBack;
	}

	/** 用户类型 IN OUT 内外部用户 */
	public String getEmpType() {
		return empType;
	}

	public void setEmpType(String empType) {
		this.empType = empType;
	}

	public String getOrgName() {
		return orgName;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}

	public String getOrgId() {
		List<UserInfoVo> userOrgList = EmployeeCached.getUserInfosByEmpId(ID, true, false);
		String secondOrgid = userOrgList.get(0).getSecondOrgid();
		return secondOrgid;
	}

	public String getEmpStat() {
		return empStat;
	}

	public void setEmpStat(String empStat) {
		this.empStat = empStat;
	}

	public String getCompany() {
		return company;
	}

	public void setCompany(String company) {
		this.company = company;
	}

	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}
	
	public String getDueDate() {
		return dueDate;
	}

	public void setDueDate(String dueDate) {
		this.dueDate = dueDate;
	}

	public boolean isDue() {
		if(StringUtils.isBlank(dueDate)) {  // 没有过期日，说明永远不过期
			return false;
		}
		int compare = DateUtils.compare(dueDate, DateUtils.getNowStr(DateUtils.DATE_FORMAT_yMd_EN), DateUtils.DATE_FORMAT_yMd_EN);
		// 过期日小于当前时间，已过期
		return compare < 0 ? true : false; 
	}

}
